package com.ruoyi.aop;

import com.ruoyi.app.home.entity.LoveMessage;
import com.ruoyi.app.home.mapper.SysLoveMessageMapper;
import com.ruoyi.common.utils.DateUtils;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LoveMessageAspect {
    
    @Autowired
    private SysLoveMessageMapper loveMessageMapper;
    
    @AfterReturning(
        pointcut = "execution(public String com.ruoyi.common.utils.DeepSeekUtil.generateLoveMessage())",
        returning = "message"
    )
    public void saveLoveMessage(String message) {
        LoveMessage loveMessage = new LoveMessage();
        loveMessage.setMessage(message);
        loveMessage.setCreateTime(DateUtils.getNowDate());
        loveMessageMapper.insert(loveMessage);
    }
}
